<?php
// 应用公共文件
function substr_cut($str_cut,$length)
{
    if (strlen($str_cut) > $length)
    {
        for($i=0; $i < $length; $i++)
            if (ord($str_cut[$i]) > 128)    $i++;
        $str_cut = substr($str_cut,0,$i)."..";
    }
    return $str_cut;
}


/*
 * 获取时分秒，转化成秒
 * 8时5分5秒
 */
function turnSecond($str){
    $hour = 0;
    $minute = 0;
    $second = 0;
    if(strpos($str,'时') !== false){
        $strArr1 = explode('时',$str);
        $hour = $strArr1[0];
        $strArr2 = explode('分',$strArr1[1]);
        $minute = $strArr2[0];
        $strArr3 = explode('秒',$strArr2[1]);
        $second = $strArr3[0];
    }else{
        if(strpos($str,'分') !== false){
            $strArr1 = explode('分',$str);
            $minute = $strArr1[0];
            $strArr2 = explode('秒',$strArr1[1]);
            $second = $strArr2[0];
        }else{
            if(strpos($str,'秒') !== false){
                $strArr = explode('秒',$str);
                $second = $strArr[0];
            }
        }
    }
    $num = $hour * 3600 + $minute * 60 + $second;
    return $num;
}
